import 'package:flutter/material.dart';

class DetailPage extends StatelessWidget {
  const DetailPage({super.key});

  @override
  Widget build(BuildContext context) {
    // 从路由中获取参数
    final Map<String, dynamic>? arguments =
        ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>?;
    print(arguments);

    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text('详情页'),
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: const BoxDecoration(color: Colors.green),
        child: Column(
          children: [
            const Text('详情页'),
            ElevatedButton(
                onPressed: () {
                  Navigator.pop(context);
                },
                child: const Text('返回')),
            ElevatedButton(
                onPressed: () {
                  showDialog(
                      context: context,
                      builder: (context) => AlertDialog(
                            title: const Text('温馨提示'),
                            content: const Text('弹窗可以看作一个特殊页面'),
                            actions: [
                              ElevatedButton(
                                  onPressed: () {
                                    Navigator.pop(context);
                                  },
                                  child: const Text('确定'))
                            ],
                          ));
                },
                child: const Text('弹窗'))
          ],
        ),
      ),
    );
  }
}
